﻿<UserControl x:Class="ToDoList.Views.EditView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:SampleData="clr-namespace:ToDoList.SampleData"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:Behaviors="clr-namespace:ToDoList.Behaviors" xmlns:System="clr-namespace:System;assembly=mscorlib"
             mc:Ignorable="d"
    d:DesignHeight="430" d:DesignWidth="430">

    <Grid x:Name="LayoutRoot" Width="420" Height="420">        
        <Grid.RenderTransform>
            <TransformGroup>
                <ScaleTransform/>
                <TranslateTransform/>
            </TransformGroup>
        </Grid.RenderTransform>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="VisibilityStates">
                <VisualStateGroup.States>
                <VisualState x:Name="New">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusHelper" Storyboard.TargetProperty="(FocusHelper.SetFocus)">
                                <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <System:Boolean>true</System:Boolean>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                </VisualState>
                <VisualState x:Name="Edit">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusHelper" Storyboard.TargetProperty="(FocusHelper.SetFocus)">
                                <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <System:Boolean>true</System:Boolean>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                </VisualState>
                <VisualState x:Name="Closed">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                </VisualStateGroup.States>
                <VisualStateGroup.Transitions>
                    <VisualTransition To="New" GeneratedDuration="0">
                        <Storyboard>                            
                            <DoubleAnimation 
                                Duration="0:0:0.3"
                                Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                                             From="0" To="1.0">
                                <DoubleAnimation.EasingFunction>
                                    <CircleEase EasingMode="EaseOut"/>
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                            <DoubleAnimation 
                                Duration="0:0:0.3"
                                Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                                             From="0" To="1.0">
                                <DoubleAnimation.EasingFunction>
                                    <CircleEase EasingMode="EaseOut"/>
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                            <DoubleAnimation 
                                Duration="0:0:0.3"
                                Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(ScaleTransform.X)"
                                             From="400" To="0"/>
                            <DoubleAnimation 
                                Duration="0:0:0.3"
                                Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(ScaleTransform.Y)"
                                             From="-200" To="0"/>
                        </Storyboard>
                    </VisualTransition>
                    <VisualTransition To="Edit" GeneratedDuration="0">
                        <Storyboard>
                            <DoubleAnimation 
                                Duration="0:0:0.3"
                                Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                                             From="0" To="1.0">
                                <DoubleAnimation.EasingFunction>
                                    <CircleEase EasingMode="EaseOut"/>
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                            <DoubleAnimation 
                                Duration="0:0:0.3"
                                Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                                             From="0" To="1.0">
                                <DoubleAnimation.EasingFunction>
                                    <CircleEase EasingMode="EaseOut"/>
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>                            
                        </Storyboard>
                    </VisualTransition>
                    <VisualTransition To="Closed" From="New" GeneratedDuration="0">
                        <Storyboard>
                            <DoubleAnimation 
                                Duration="0:0:0.3"
                                Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                                             From="1.0" To="0">
                                <DoubleAnimation.EasingFunction>
                                    <CircleEase EasingMode="EaseIn"/>
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                            <DoubleAnimation 
                                Duration="0:0:0.3"
                                Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                                             From="1.0" To="0">
                                <DoubleAnimation.EasingFunction>
                                    <CircleEase EasingMode="EaseIn"/>
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                            <DoubleAnimation 
                                Duration="0:0:0.3"
                                Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(ScaleTransform.X)"
                                             From="0" To="400"/>
                            <DoubleAnimation 
                                Duration="0:0:0.3"
                                Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(ScaleTransform.Y)"
                                             From="0" To="-200"/>
                        </Storyboard>
                    </VisualTransition>
                    <VisualTransition To="Closed" From="Edit" GeneratedDuration="0">
                        <Storyboard>
                            <DoubleAnimation 
                                Duration="0:0:0.3"
                                Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                                             From="1.0" To="0">
                                <DoubleAnimation.EasingFunction>
                                    <CircleEase EasingMode="EaseIn"/>
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                            <DoubleAnimation 
                                Duration="0:0:0.3"
                                Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                                             From="1.0" To="0">
                                <DoubleAnimation.EasingFunction>
                                    <CircleEase EasingMode="EaseIn"/>
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>                            
                        </Storyboard>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Rectangle HorizontalAlignment="Stretch"
                   VerticalAlignment="Stretch"
                   Fill="Black"
                   Opacity="0.5"/>
    <Grid Width="400" Height="400" Background="{StaticResource DarkControlBackgroundBrush}"
          d:DataContext="{d:DesignInstance SampleData:DesignEditViewModel, IsDesignTimeCreatable=True}">        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <TextBlock Text="ID:"/>
        <TextBlock Text="{Binding Id}" Grid.Column="1"/>
            <Behaviors:FocusHelper x:Name="FocusHelper" TargetElement="{Binding ElementName=Title}"/>
            <TextBlock Text="{Behaviors:Localize Resource=Title, AsLabel=True, Default=Title}" Grid.Row="1"/>
            <TextBox x:Name="Title" Text="{Binding Title,Mode=TwoWay}" HorizontalAlignment="Left" Grid.Row="1" Grid.Column="1">
                <i:Interaction.Behaviors>
                    <Behaviors:TextBoxChangedBehavior/>
                </i:Interaction.Behaviors>
            </TextBox>
            <TextBlock Text="{Behaviors:Localize Resource=DueDate, AsLabel=True, Default='Due Date'}" Grid.Row="2"/>
        <TextBox Text="{Binding DueDate,Mode=TwoWay}" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="1"/>
        <TextBlock Text="{Behaviors:Localize Resource=Description, AsLabel=True, Default=Description}" Grid.Row="3"/>
            <TextBox Text="{Binding Description,Mode=TwoWay}" 
                 TextWrapping="Wrap"
                 HorizontalAlignment="Left" 
                 Width="300" Height="150"
                 Grid.Row="3" Grid.Column="1">
                <i:Interaction.Behaviors>
                    <Behaviors:TextBoxChangedBehavior/>
                </i:Interaction.Behaviors>
            </TextBox>
            <TextBlock Text="{Behaviors:Localize Resource=Link, AsLabel=True, Default=Link}" Grid.Row="4"/>
            <StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="1">
                <TextBox Text="{Binding TextLink,Mode=TwoWay}" HorizontalAlignment="Left">
                <i:Interaction.Behaviors>
                    <Behaviors:TextBoxChangedBehavior/>
                </i:Interaction.Behaviors>
            </TextBox>
                <HyperlinkButton Content="Test Link" NavigateUri="{Binding Link}" TargetName="_blank"
                                 IsEnabled="{Binding LinkNoErrors}"
                                 VerticalAlignment="Center"/>
            </StackPanel>
            <StackPanel Grid.Row="5" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Content="CANCEL" Style="{StaticResource OrangeButton}"
                    Command="{Binding CancelCommand}" />
            <Button Content="SAVE" Style="{StaticResource OrangeButton}"
                    Command="{Binding CommitCommand}"/>
        </StackPanel>
    </Grid>
    </Grid>
</UserControl>
